//
//  DetailCompereViewController.m
//  JZMCFM
//
//  Created by Mc on 15/10/31.
//  Copyright (c) 2015年 陈卓. All rights reserved.
//

#import "DetailCompereViewController.h"
#import "DetailCompereTableViewCell.h"
#import "DetailCompereViewController2.h"
@interface DetailCompereViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *mainTableView;

@end

@implementation DetailCompereViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.mainTableView.delegate = self;
    self.mainTableView.dataSource = self;
    
    [self.mainTableView registerNib:[UINib nibWithNibName:@"DetailCompereTableViewCell" bundle:nil] forCellReuseIdentifier:@"aaa"];
    
    [[DetailCompereHelp sharedInstance] downLoadWithUrlString:[NSString stringWithFormat:@"%@%@%@",kDetailFirst,self.name,kDetailLast] WithResultBlock:^{
        [self.mainTableView reloadData];
    }];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [DetailCompereHelp sharedInstance].detailArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    DetailCompereTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"aaa" forIndexPath:indexPath];
    DetailCompereModel *p = [DetailCompereHelp sharedInstance].detailArray[indexPath.row];
    [cell setCellWithModel:p];
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 150;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    DetailCompereViewController2 *vc = [[DetailCompereViewController2 alloc] init];
    DetailCompereModel *p = [DetailCompereHelp sharedInstance].detailArray[indexPath.row];
    vc.uid = p.uid;
    vc.title = p.nickname;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
